package com.zzw.mvvm.repository.local;

import android.database.Observable;

import com.zzw.mvvm.beans.DemoEntity;

import java.util.List;

import androidx.room.Dao;
import androidx.room.Delete;
import androidx.room.Insert;
import androidx.room.OnConflictStrategy;
import androidx.room.Query;
import io.reactivex.Flowable;

@Dao
public interface DemoDao {
    @Query("SELECT * FROM demoentity")
    List<DemoEntity> getAll();

    @Query("SELECT * FROM demoentity WHERE name IN (:userIds)")
    List<DemoEntity> loadAllByIds(int[] userIds);

    @Query("SELECT * FROM demoentity WHERE name LIKE :first AND "
            + "aget LIKE :last LIMIT 1")
    Flowable<DemoEntity> findByName(String first, String last);

    @Insert(onConflict = OnConflictStrategy.REPLACE)//冲突策略 替换
    void insertAll(DemoEntity... users);

    @Delete
    void delete(DemoEntity user);
}
